# 此处设置系统名称与处理器类型，此为必须项
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

# 设置交叉编译所需的编译器
set(CMAKE_C_COMPILER   /opt/pi_chaintool/tool/arm-gcc)
set(CMAKE_CXX_COMPILER /opt/pi_chaintool/tool/arm-g++)

# 设置目标系统sysroot，一定要设置对，否则会报交叉编译器broken，无法正确进行cmake
set(CMAKE_SYSROOT /opt/pi_toolchain/sysroot)

# 设置编译时查找库与头文件的路径，此处设为只在sysroot中查找，可以对应到目标板的系统
set(CMAKE_FIND_ROOT_PATH  ${CMAKE_SYSROOT})
# 设置只在CMAKE_FIND_ROOT_PATH中查找编译需要的库与头文件
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

# 设置编译优化选项
set(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE INTERNAL "c compiler flags debug")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -std=gnu++11" CACHE INTERNAL "cxx compiler flags debug")
set(CMAKE_C_FLAGS_RELEASE "-O3 -s" CACHE INTERNAL "c compiler flags release")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -std=gnu++11 -s -fPIC -D_GNU_SOURCE" CACHE INTERNAL "cxx compiler flags release") #-Wall

# 输出一些关键信息，message为cmake语法
message(STATUS "BUILD TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} CMAKE_CXX_FLAGS is: ${CMAKE_CXX_FLAGS}")
